package cn.cloudbae.config.jobconig;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;

@Configuration
public class ZookeeperRegistryCenterConfig {
	
	/**
	 * 初始化zk bean，并注入ioc容器
	 */
    @Bean(initMethod = "init")
    public ZookeeperRegistryCenter regCenter(
    		@Value("${esjob.regCenter.serverList}") String serverList
            , @Value("${esjob.regCenter.namespace}") String namespace) {
    	ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(serverList, namespace);
        return new ZookeeperRegistryCenter(zkConfig);
    }
}
